
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
        <title>直播后台 - 登录</title>
		
		<!-- Favicon -->
        <link rel="shortcut icon" type="image/x-icon" href="/public/assets/img/favicon.png">

		<!-- Bootstrap CSS -->
        <link rel="stylesheet" href="http://cdn.bootstrapmb.com/bootstrap/4.3.1/css/bootstrap.min.css">
		
		<!-- Fontawesome CSS -->
        <link rel="stylesheet" href="/public/assets/css/font-awesome.min.css">
		
		<!-- Main CSS -->
        <link rel="stylesheet" href="/public/assets/css/style.css">
		
		<!--[if lt IE 9]>
			<script src="/public/assets/js/html5shiv.min.js"></script>
			<script src="/public/assets/js/respond.min.js"></script>
        <![endif]-->
        

        <!-- jQuery -->
        <script src="/public/assets/js/jquery-3.2.1.min.js"></script>
		
		<!-- Bootstrap Core JS -->
        <script src="/public/assets/js/popper.min.js"></script>
        <script src="http://cdn.bootstrapmb.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
		
		<!-- Custom JS -->
        <script src="/public/assets/js/script.js"></script>
        
        <script src="/public/assets/js/vue.min.js"></script>
		<script src="/public/assets/js/vue.component.js"></script>

    </head>
    <body>
	
		<!-- Main Wrapper -->
        <div class="main-wrapper login-body" id="vueapp">

            <!-- 提示框 -->
            <toast ref="toast"></toast>
			<confirm ref="confirm"></confirm>

            <div class="login-wrapper">
            	<div class="container">
                	<div class="loginbox">
                    	<div class="login-left">
							<img class="img-fluid" src="/public/assets/img/logo.png" alt="Logo">
                        </div>
                        <div class="login-right">
							<div class="login-right-wrap">
								<h1>登 录</h1>
								<p class="account-subtitle">Access to our dashboard</p>
								
								<!-- Form -->
								<form>
									<div class="form-group">
										<input class="form-control" type="text" placeholder="输入用户名..." v-model="form.username">
									</div>
									<div class="form-group">
										<input class="form-control" type="text" placeholder="输入密码..." v-model="form.password">
									</div>
									<div class="form-group">
										<button @click.stop.prevent="submit" class="btn btn-primary btn-block" type="submit">登 录</button>
									</div>
								</form>
								  
							</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
		<!-- /Main Wrapper -->
		<script>
            new Vue({
                el:"#vueapp",
                data() {
                    return {
                        form:{
                            username:"",
                            password:""
                        }
                    }
                },
                // 页面加载完毕
                mounted() {
                    var toast = "{{ toast.msg }}"
                    if(toast && this.$refs.toast){
                        this.$refs.toast.show({
                            msg:"{{ toast.msg }}",
                            type:"{{ toast.type }}"
                        })
                    }
                },
                methods: {
                    submit:function(){
                        var _t = this
                        $.ajax({
                            type:"POST",
                            contentType:"application/json;charset=UTF-8",
                            url:"/admin/loginevent?_csrf={{ ctx.csrf | safe }}",
                            data:JSON.stringify(this.form),
                            success:function(result){
                                console.log(result)
                                _t.$refs.toast.show({
                                    msg:"登录成功",
                                    type:"success",
                                    success:function(){
                                        window.location.href = '/admin'
                                    }
                                })
                            },
                            error:function(e){
                                _t.$refs.toast.show({
                                    msg:e.responseJSON.data
                                })
                            }
                        })
                    }
                },
            })
        </script>
		
		
    </body>
</html>
